# let's do some simple verification
inputFileName1 = "/data5/team/weijiang/the_new_trip_of_feature_generation/final-complexFeaturesSupportedFileBothModeForTf_dicts.txt"
#inputFileName2 = "/data5/team/weijiang/the_new_trip_of_feature_generation/final-complexFeaturesSupportedFileDebugForCf_dicts.txt"
#inputFileName3 = "/data5/team/weijiang/the_new_trip_of_feature_generation/final-complexFeaturesSupportedFileDebugForDf_dicts.txt"

inputFileHandler1 = open(inputFileName1,"r")
#inputFileHandler2 = open(inputFileName2,"r")
#inputFileHandler3 = open(inputFileName3,"r")

inputFileHandler1.readline()
#inputFileHandler2.readline()
#inputFileHandler3.readline()


Cf_dicts = {}
Df_dicts = {}

for i in range(31,41):
    
    cf_dict = {}
    cf_dict["M_1"] = 0
    cf_dict["M_4"] = 0
    cf_dict["M_8"] = 0
    cf_dict["M_32"] = 0
    
    cf_dict["N_ordered_1"] = 0
    cf_dict["N_ordered_4"] = 0
    cf_dict["N_ordered_8"] = 0
    cf_dict["N_ordered_32"] = 0
    
    cf_dict["N_unordered_1"] = 0
    cf_dict["N_unordered_4"] = 0
    cf_dict["N_unordered_8"] = 0
    cf_dict["N_unordered_32"] = 0    
    
    df_dict = {}
    df_dict["M_1"] = 0
    df_dict["M_4"] = 0
    df_dict["M_8"] = 0
    df_dict["M_32"] = 0
    
    df_dict["N_ordered_1"] = 0
    df_dict["N_ordered_4"] = 0
    df_dict["N_ordered_8"] = 0
    df_dict["N_ordered_32"] = 0
    
    df_dict["N_unordered_1"] = 0
    df_dict["N_unordered_4"] = 0
    df_dict["N_unordered_8"] = 0
    df_dict["N_unordered_32"] = 0    
        
    Cf_dicts[i] = cf_dict
    Df_dicts[i] = df_dict
    
    
    
    
for line in inputFileHandler1.readlines():
    lineElements = line.strip().split(" ")
    
    variantID = int(lineElements[0])
    # print variantID
    
    trecID = lineElements[1]
    
    tf_M_1 = int( lineElements[2] )
    tf_M_4 = int( lineElements[3] )
    tf_M_8 = int( lineElements[4] )
    tf_M_32 = int( lineElements[5] )
    tf_N_ordered_1 = int( lineElements[6] )
    tf_N_ordered_4 = int( lineElements[7] )
    tf_N_ordered_8 = int( lineElements[8] )
    tf_N_ordered_32 = int( lineElements[9] )
    tf_N_unordered_1 = int( lineElements[10] )
    tf_N_unordered_4 = int( lineElements[11] )
    tf_N_unordered_8 = int( lineElements[12] )
    tf_N_unordered_32 = int( lineElements[13] )
    
    
    if variantID >= 31 and variantID < 41:
        Cf_dicts[variantID]["M_1"] += tf_M_1
        Cf_dicts[variantID]["M_4"] += tf_M_4
        Cf_dicts[variantID]["M_8"] += tf_M_8
        Cf_dicts[variantID]["M_32"] += tf_M_32
        
        Cf_dicts[variantID]["N_ordered_1"] += tf_N_ordered_1
        Cf_dicts[variantID]["N_ordered_4"] += tf_N_ordered_4
        Cf_dicts[variantID]["N_ordered_8"] += tf_N_ordered_8
        Cf_dicts[variantID]["N_ordered_32"] += tf_N_ordered_32
        
        Cf_dicts[variantID]["N_unordered_1"] += tf_N_unordered_1
        Cf_dicts[variantID]["N_unordered_4"] += tf_N_unordered_4
        Cf_dicts[variantID]["N_unordered_8"] += tf_N_unordered_8
        Cf_dicts[variantID]["N_unordered_32"] += tf_N_unordered_32 
        
        if tf_M_1 != 0:
            Df_dicts[variantID]["M_1"] += 1
        
        if tf_M_4 != 0:
            Df_dicts[variantID]["M_4"] += 1

        if tf_M_8 != 0:
            Df_dicts[variantID]["M_8"] += 1

        if tf_M_32 != 0:
            Df_dicts[variantID]["M_32"] += 1
            
        if tf_N_ordered_1 != 0:
            Df_dicts[variantID]["N_ordered_1"] += 1

        if tf_N_ordered_4 != 0:
            Df_dicts[variantID]["N_ordered_4"] += 1        
        
        if tf_N_ordered_8 != 0:
            Df_dicts[variantID]["N_ordered_8"] += 1
        
        if tf_N_ordered_32 != 0:
            Df_dicts[variantID]["N_ordered_32"] += 1
            
        if tf_N_unordered_1 != 0:
            Df_dicts[variantID]["N_unordered_1"] += 1

        if tf_N_unordered_4 != 0:
            Df_dicts[variantID]["N_unordered_4"] += 1

        if tf_N_unordered_8 != 0:
            Df_dicts[variantID]["N_unordered_8"] += 1

        if tf_N_unordered_32 != 0:
            Df_dicts[variantID]["N_unordered_32"] += 1

print "Cf_dicts related..."
for variantID in range(31,41):       
    print variantID,Cf_dicts[variantID]["M_1"],
    print Cf_dicts[variantID]["M_4"],
    print Cf_dicts[variantID]["M_8"],
    print Cf_dicts[variantID]["M_32"],
    
    print Cf_dicts[variantID]["N_ordered_1"],
    print Cf_dicts[variantID]["N_ordered_4"],
    print Cf_dicts[variantID]["N_ordered_8"],
    print Cf_dicts[variantID]["N_ordered_32"],

    print Cf_dicts[variantID]["N_unordered_1"],
    print Cf_dicts[variantID]["N_unordered_4"],
    print Cf_dicts[variantID]["N_unordered_8"],
    print Cf_dicts[variantID]["N_unordered_32"]


print "Df_dicts related..."
for variantID in range(31,41):       
    print variantID,Df_dicts[variantID]["M_1"],
    print Df_dicts[variantID]["M_4"],
    print Df_dicts[variantID]["M_8"],
    print Df_dicts[variantID]["M_32"],
    
    print Df_dicts[variantID]["N_ordered_1"],
    print Df_dicts[variantID]["N_ordered_4"],
    print Df_dicts[variantID]["N_ordered_8"],
    print Df_dicts[variantID]["N_ordered_32"],

    print Df_dicts[variantID]["N_unordered_1"],
    print Df_dicts[variantID]["N_unordered_4"],
    print Df_dicts[variantID]["N_unordered_8"],
    print Df_dicts[variantID]["N_unordered_32"]
    
    
    
    
    
    
    
    
